import type {App} from 'vue';
import {createRouter, createWebHistory} from 'vue-router';

import {setupRouterGuard} from './guard/index';
import {homeModuleRouter} from './modules/home';
import {systemModuleRouter} from './modules/system';
import {errorModuleRouter} from './modules/error';
import {remainingModuleRouter} from './modules/remaining';

/** 原始静态路由（未做任何处理） */
const routes: any[] = [homeModuleRouter, systemModuleRouter, errorModuleRouter, ...remainingModuleRouter];

// console.log('路由', routes);
export const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
  strict: true,
});



// 配置路由器
export function setupRouter(app: App<Element>) {
  app.use(router);
  setupRouterGuard(router);
}
export default router;
